package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppZhiye;
import com.vf.admin.miaodong.entity.AppZhiyeFu;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 职业父级
 * @author anxiang
 */
@Repository
public class AfterZhiyeFuDao extends BaseDao<AppZhiyeFu> {

    /**
     * 查询列表
     */
    public List<AppZhiyeFu> list(Map<String, Object> paraMap, SplitPageBean splitPage) {
        ArrayList<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_zhiye_fu where 1=1  ");

        if (StringEx.isNotNull(paraMap.get("name"))) {
            sbStr.append(" and name like ? ");
            paramList.add("%"+paraMap.get("name")+"%");
        }
        if (StringEx.isNotNull(paraMap.get("code"))) {
            sbStr.append(" and code like ? ");
            paramList.add("%"+paraMap.get("code")+"%");
        }

        sbStr.append(" order by id asc");
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, AppZhiyeFu.class, splitPage);
    }

    /**
     * 详情
     */
    public AppZhiyeFu get(Integer id) {
        if (StringEx.isNullOrLing(id)) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_zhiye_fu where 1=1");
        sbStr.append(" and id = ? ");
        paramList.add(id);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppZhiyeFu.class);
    }

    /**
     * 详情
     */
    public AppZhiyeFu getCode(Integer code) {
        if (StringEx.isNullOrLing(code)) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_zhiye_fu where 1=1");
        sbStr.append(" and code = ? ");
        paramList.add(code);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppZhiyeFu.class);
    }

    /**
     * 添加/修改
     */
    public void save(AppZhiyeFu pojo) {
        if (pojo.getId() != null && pojo.getId() > 0) {
            this.update(pojo);
        } else {
            pojo.setId(this.add(pojo));
        }
    }

}
